package com.ad2campaign.engine.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ad2campaign.engine.rest.Loadbalancer;
import com.ad2campaign.engine.rest.NodesLoader;
import com.ad2campaign.engine.rest.RestActionResponse;

public class NodesController 
{
	@Autowired
	private Loadbalancer loadbalancer;
	
	@Autowired
	private NodesLoader nodesLoader;
	
	
	@RequestMapping("/nodes/reload/")
	@ResponseBody public void reloadNodes()
	{
 		 loadbalancer.refresh();
 	}
 	
	@RequestMapping("/nodes/")
	@ResponseBody public void nodes()
	{
		RestActionResponse response = new RestActionResponse();
		response.setStatus(true);
		response.setData(nodesLoader.loadNodes());
 	}
 	
}
